home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.2 Development Libraries / SGI IRIX 6.2 Development Libraries.iso / dist / complib.idb / usr / share / src / Complib / examples / scfftm1d_ex.c.z / scfftm1d_ex.c
C/C++ Source or Header  |  1996-03-14  |  3KB  |  85 lines

  1. /*
  2.  * scfftm1d_ex.c
  3.  *
  4.  *       This simple example illustrates the use of the FORTRAN
  5.  *       interface to a real-to-complex multiple FFT routines by
  6.  *       calculating a circular shift.
  7.  *
  8.  *
  9.  * Copyright 1995, Silicon Graphics, Inc.
  10.  * ALL RIGHTS RESERVED
  11.  *
  12.  * UNPUBLISHED -- Rights reserved under the copyright laws of the United
  13.  * States.   Use of a copyright notice is precautionary only and does not
  14.  * imply publication or disclosure.
  15.  *
  16.  * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
  17.  * Use, duplication or disclosure by the Government is subject to restrictions
  18.  * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
  19.  * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
  20.  * in similar or successor clauses in the FAR, or the DOD or NASA FAR
  21.  * Supplement.  Contractor/manufacturer is Silicon Graphics, Inc.,
  22.  * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
  23.  *
  24.  * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
  25.  * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
  26.  * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
  27.  * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
  28.  * GRAPHICS, INC.
  29.  *
  30.  *      To build executable:
  31.  *         % cc -o scfftm1d_ex scfftm1d_ex.c -lcomplib.sgimath -lm
  32.  *
  33.  *      To run executable:
  34.  *       % scfftm1d_ex 3 4
  35.  *       Printing " Input Array " of size 3 x 4 :
  36.  *           0.00    0.01    0.02    0.03
  37.  *           1.00    1.01    1.02    1.03
  38.  *           2.00    2.01    2.02    2.03
  39.  *       Printing " Loop on 1D FFTs - stride 1  " of size 4 x 4 :
  40.  *           3.00    3.03    3.06    3.09
  41.  *           0.00    0.00    0.00    0.00
  42.  *          -1.50   -1.50   -1.50   -1.50
  43.  *           0.87    0.87    0.87    0.87
  44.  *       Printing " Multiple1D FFTs - stride 1  " of size 4 x 4 :
  45.  *           3.00    3.03    3.06    3.09
  46.  *           0.00    0.00    0.00    0.00
  47.  *          -1.50   -1.50   -1.50   -1.50
  48.  *           0.87    0.87    0.87    0.87
  49.  *
  50.  */
  51.  
  52. #include <stdio.h>
  53. #include <fft.h>
  54.  
  55. void print_2D_array( int M, int N, char string[], float array[], int ld) {
  56.     int i, j;
  57.     printf( "Printing \" %s \" of size %d x %d :\n", string, M, N);
  58.     for( i = 0 ; i < M ; i++, array++) {
  59.       for( j= 0; j < N ; j++ ) printf(" %7.2f", array[j*ld]);
  60.       printf("\n");
  61.     }
  62. }
  63.  
  64.  
  65. main( int argc, char *argv[]) {
  66.  
  67. #define SIZE 8
  68.     int i, j, M, N, offset;
  69.     float Array1[2*((SIZE+2)/2)*SIZE], Array2[2*((SIZE+2)/2)*SIZE], *coef;
  70.     M = atoi( argv[1]); N = atoi( argv[2]);
  71.  
  72.     for( j = 0 ; j < N ; j ++ )
  73.       for ( i = 0 ; i < (M+2) ; i++) 
  74.         Array1[i+(M+2)*j] = Array2[i+(M+2)*j] = (float)i + 0.01 * (float)j;
  75.     print_2D_array( M, N, "Input Array", Array1, M+2);
  76.  
  77.     coef = sfft1dui( M, NULL);
  78.     for( j = 0 ; j < N ; j++)
  79.         scfft1du( -1, M, Array1+j*(M+2), 1, coef);
  80.     scfftm1du( -1, M, N, Array2, 1, (M+2), coef);
  81.  
  82.     print_2D_array( 2*((M+2)/2),N, "Loop on 1D FFTs - stride 1 ",Array1,M+2);
  83.     print_2D_array( 2*((M+2)/2),N, "Multiple1D FFTs - stride 1 ",Array2,M+2);
  84. }
  85.